/**
 * Created by ${PRODUCT_NAME}.
 * User: skylerparr
 * Date: 12/26/10
 * Time: 11:52 AM
 * To change this template use File | Settings | File Templates.
 */
package com.thoughtorigin.loader {
import flash.events.Event;
import flash.events.IEventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;

public class URLLoaderItem extends LoaderItem {

    private var _loader: URLLoader;

    public function URLLoaderItem(url: String) {
        super(url);
    }

    override public function start():void {
        if(isLoading) {
            return;
        }

        isLoading = true;
        _loader = createLoader();
        addListeners();

        _loader.load(urlRequest);
    }

    override protected function cleanupAndDispatch(e:Event):void {
        dispatchEvent(e);
        removeListeners();
    }

    override public function get content():* {
        return _loader.data;
    }

    override public function get contentDispatcher():IEventDispatcher {
        return _loader;
    }

    override protected function createLoader():* {
        return new URLLoader();
    }
}
}
